<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>sessionStorage</title>
	</head>
	<body>
		<h2>学习sessionStorage的使用</h2>
		<button onclick="savePerson()">将一个人存入sessionStorage</button> <br><br>
		<button onclick="getPerson()">从sessionStorage根据key取出value</button> <br><br>
		<button onclick="deletePerson()">从sessionStorage中删除一组数据</button> <br><br>
		<button onclick="updatePerson()">从sessionStorage中根据key修改一个value</button> <br><br>
		<button onclick="qingkong()">清空sessionStorage</button> <br><br>

		<script type="text/javascript" >

			let person = {
				name:'老刘',
				age:18,
				gneder:'男'
			}
			let person2 = {
				name:'强姐姐',
				age:17,
				gneder:'女'
			}

			function savePerson(){
				sessionStorage.setItem('ren',JSON.stringify(person))
			}

			function getPerson(){
				const x = sessionStorage.getItem('rennnnnnn')
				console.log(x)
				console.log(JSON.parse(x))
			}

			function deletePerson(){
				sessionStorage.removeItem('ren')
			}

			function updatePerson(){
				sessionStorage.setItem('ren',JSON.stringify(person2))
			}

			function qingkong(){
				sessionStorage.clear()
			}

		</script>
	</body>
</html>